define(['app','echarts','echartsGL'],function(app,echarts){return {module: function($scope, $http, eventBusService, httpService, params, configService) {


	httpService.post(app.urls.error_selectCount,{"fk_unit":'self'}, function (data) {
		if ("0000" === data.code) {
			$scope.error = data.data;
		} else {
			alert(data.msg);
		}
	});
	$scope.update = function(row){
		var menu = {};
		if(row.sheet=='sc_user_student'){
			menu.url = "modules/content/usermanagement/student/list?father_id="+params.father_id+"&sheet="+row.sheet+"&field="+row.field+"&type="+row.type+"&father_id=undefined";
		}
		if(row.sheet=='sc_user_teacher'){
			menu.url = "modules/content/usermanagement/teacher/list?father_id="+params.father_id+"&sheet="+row.sheet+"&field="+row.field+"&type="+row.type+"&father_id=undefined";
		}
		eventBusService.publish("modules.content.load",menu);
	}

	$scope.find = function () {
		httpService.post(app.urls.unit_selectCountAtSchool, $scope.form, function (data) {
			if ("0000" === data.code) {
			 $scope.rows = data.data;
			 $scope.findtb();
			} else {
				alert(data.msg);
			}
		});
   }
		 
	$scope.find();
	
	 $scope.findtb = function () {
         httpService.post(app.urls.unit_selectSubjectTeacherCountAtSchool, $scope.form, function (data) {
             if ("0000" === data.code) {
            	 
            	 $scope.xkjs = data.data;
            	 
            	 $scope.dataname = [];
            	 $scope.datanum = [];
            	 
            	 for(var i=0 ; i<$scope.xkjs.length ; i++ ){
            		 $scope.dataname.push($scope.xkjs[i].name);
            		 $scope.datanum.push($scope.xkjs[i].num);
            	 }
            	 
            	 $scope.echartsInit();
             } else {
                 alert(data.msg);
             }
         });
    }
	
	$scope.echartsInit = function(){
		var dom = document.getElementById("data_xk_teacher");
		var myChart = echarts.init(dom);
		var app = {};
		option = null;
		app.title = '多 X 轴示例';
		
		option = {
			    backgroundColor: '#fff',
			    color: "rgba(91, 143, 249, 1)",
			    tooltip: {
			        show: "true",
			    },
			    grid: {
			        left: '0%',
			        right: '0%',
			        top: '10%',
			        bottom: '0%',
			        containLabel: true
			    },
			    yAxis: {
			        type: 'value',
			        axisTick: {
			            show: false
			        },
			        axisLine: {
			            show: false,
			            lineStyle: {
			                color: '#416180',
			            }
			        },
			        axisLabel: {
			            show: true,
			            color: "#A0A4AA",
			            fontSize: 12,
			        },
			         splitLine: {
			            show: true,
			            lineStyle: { 
			                color: 'rgba(65, 97, 128, 0.15)',
			            }
			        },


			    },
			    xAxis: [{
			        axisTick: {
			            show: false
			        },
			       
			        type: 'category',
			        axisLine: {
			            show: false
			        },
			        axisLabel: {
			            show: true,
			            color: '#A0A4AA',
			            interval: 0,  
			            rotate:'25',
			            fontSize: 10,
			        },
			        splitLine: {
			            show: false,
			            lineStyle: {
			                color: '#416180',
			            }
			        },
			        data: $scope.dataname,
			    }],
			    series: [{
			        name: '人数',
			        type: 'bar',
			        barWidth: 15,
			        label: {
			            normal: {
			                show: false,
			                position: 'right',
			                textStyle: {
			                    color: "#ccc",
			                    fontSize: 14
			                }
			            }
			        },
			        data: $scope.datanum
			    }]
			};;
		if (option && typeof option === "object") {
		    myChart.setOption(option, true);
		}
	}
	httpService.post(app.urls.getUserIP,{}, function (data) {
		if ("0000" === data.code) {
			$scope.ipinfo = data.data;
		} else {
			alert(data.msg);
		}
	});
}}});